package com.example.demo.线程池;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @description:
 * @projectName:demo
 * @see:线程池
 * @author:袁成龙
 * @createTime:2020/10/6 20:16
 * @version:1.0
 */
public class MyRejectHeader implements RejectedExecutionHandler {

   private LinkedBlockingQueue<Runnable> blockingQueue;

    public MyRejectHeader(LinkedBlockingQueue<Runnable> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    public MyRejectHeader() {
    }

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        try {
            blockingQueue.put(r);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}